import { ref, reactive } from "vue";
import { FormInstance } from "element-plus";

export const useData = () => {
  const formData = ref({
    id: undefined,
    remark: "",
    typeId: undefined,
    code: "",
    name: "",
    picture: "",
    specifiedLoad: undefined,
    specifiedLoadDistance: undefined,
    loadHeight: undefined,
    loadLineChartPath: "",
    radarHeight: undefined,
    forkLength: undefined,
    forkWidth: undefined,
    forkThickness: undefined,
    groundHeightLow: undefined,
    groundHeightHigh: undefined,
    channelWidth: undefined,
    channelWidthSafe: undefined,
    turningRadius: undefined,
    turningRadiusMin: undefined,
    wheelMaterialId: undefined,
    wheelDrivingSize: undefined,
    wheelLoadSize: undefined,
    wheelBalanceSize: undefined,
    groundClearanceMin: undefined,
    climbFull: undefined,
    climbEmpty: undefined,
    length: undefined,
    width: undefined,
    height: undefined,
    weight: undefined,
    driveModeId: undefined,
    driveMotorPower: undefined,
    brakingMethodId: undefined,
    speedDriveFull: undefined,
    speedDriveEmpty: undefined,
    liftMotorPower: undefined,
    liftSpeedFull: undefined,
    liftSpeedEmpty: undefined,
    dropSpeedFull: undefined,
    dropSpeedEmpty: undefined,
    chargingMethodId: undefined,
    chargeRate: "",
    batteryTypeId: undefined,
    batteryVoltage: undefined,
    batteryCapacity: undefined,
    batteryLife: undefined,
    navigationId: undefined,
    positionAccuracy: undefined,
    communicationMethodId: undefined,
    title: "",
    keywords: "",
    description: "",
    propertyList: []
  });

  const ruleFormRef = ref<FormInstance>();

  const rules = reactive({
    // avatarUrl: [{ required: true, message: "请上传用户头像" }],
    // mobile: [{ required: true, pattern: /^[1][3,4,5,6,7,8,9][0-9]{9}$/, message: "请填写手机号" }],
    // totalIntegral: [{ required: false, pattern: /^[0-9]+$/, message: "只能为数字" }],
    // iceIntegral: [{ required: false, pattern: /^[0-9]+$/, message: "只能为数字" }],
    name: [{ required: true, message: "请填写" }],
    picture: [{ required: true, message: "请上传" }]
    // status: [{ required: false, message: "请选择状态" }],
    // email: [{ required: false, message: "请填写邮箱" }],
    // password: [
    //   {
    //     required: true,
    //     pattern: /^[A-Za-z0-9]{8,18}$/,
    //     message: "密码必须由字母、数字组成，区分大小写, 8-18位"
    //   }
    // ]
  });

  /**
   * 字典列表
   */

  const selectList = ref({});

  return {
    formData,
    ruleFormRef,
    rules,
    selectList
  };
};
